package com.example.nuc_ms_beta.ui.viewconstruction.mainfragment;

import android.content.Context;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.ListView;

import com.example.nuc_ms_beta.R;
import com.example.nuc_ms_beta.app.MyApplication;
import com.example.nuc_ms_beta.bean.activity.Collection;
import com.example.nuc_ms_beta.util.SharePreferencesUtil;

import java.util.ArrayList;
import java.util.List;

import cn.bmob.v3.BmobQuery;


/**
 * Created by 张博川 on 2016/9/2.
 */
public class MyFragment extends Fragment {
    private Context context;
    private View view;
    private LayoutInflater inflater;
    private LinearLayout communitylayout_collection_ly;
    private Boolean isLogin;
    private ListView communitylayout_listview;
    private String userObjectId = null;

    private List<String> newObjects = new ArrayList<>();


    public MyFragment(Context context) {
        this.context = context;
        inflater = LayoutInflater.from(context);
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        initView(container);
        return view;
    }

    private void initView(ViewGroup container) {
        this.view = inflater.inflate(R.layout.communitylayout, container, false);
        communitylayout_collection_ly = (LinearLayout) view.findViewById(R.id.communitylayout_collection_ly);
        communitylayout_listview = (ListView) view.findViewById(R.id.communitylayout_listview);
        isLogin = (Boolean) SharePreferencesUtil.getData(MyApplication.context, "isLogin", true);
        if (isLogin) {
            communitylayout_listview.setVisibility(View.GONE);
        } else {
            communitylayout_listview.setVisibility(View.VISIBLE);
            userObjectId = (String) SharePreferencesUtil.getData(MyApplication.context, "userObjectId", "0000");
            queryDate();
        }
    }

    private void queryDate() {
        final BmobQuery<Collection> queryCollection = new BmobQuery<>();
        queryCollection.addWhereEqualTo("userId", userObjectId);
    }
}
